<?php
ob_start();
session_start();
include "checksession.php";
date_default_timezone_set('Asia/Bangkok');
$id_member = $_SESSION["id_member"];
include("../connect.php");

$strSQL = "SELECT * FROM userlog WHERE id_member = '$id_member' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>Adinop Co., Ltd. was founded as an ingredients importer and local manufacturers’ distributor in 1986. We also function as an exporter of finished products</title>
        <link rel="stylesheet" href="../css/style.css"/>
        <script type="text/javascript" src="../js/jquery/jquery.js"></script>
        <script type="text/javascript" src="../js/jquery/jquery.validationEngine.js"></script>
        <link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css" />
        <!--<script language="javascript" src="../js/jquery/jquery-1.7.1.min"></script>-->
        <script type="text/javascript" src="../fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
		<link href="../images/it_service_logo.png" rel="shortcut icon" type="image/x-icon" /> 
        <script type="text/javascript" src="../fancybox/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
        <link rel="stylesheet" type="text/css" href="../fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
        <link rel="stylesheet" href="../fancybox/style.css" />
        <script type="text/javascript">
            $(function() {
                var objSet = "#txtKeyword";
                var objSetText = "ค้นหาด้วย รายงานผล, อาการเสีย";
                if ($(objSet).val() == "") {
                    $(objSet).val(objSetText);
                }
                $(objSet).focus(function() {
                    if ($(objSet).val() == objSetText) {
                        $(objSet).val("");
                    }
                }).blur(function() {
                    if ($(objSet).val() == "") {
                        $(objSet).val(objSetText);
                    }
                });
            });
        </script>
        <script type="text/javascript">

            $(document).ready(function() {

                $("#addCom").fancybox({
                    'width': '90%',
                    'height': '90%',
                    'autoScale': true,
                    'scrolling': 'auto',
                    'transitionIn': 'elastic',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'overlayColor': '#000',
                    'hideOnOverlayClick': false,
                    onCleanup: function() {
                        return window.location.reload();
                    }
                });

                $('a[id^="edit"]').fancybox({
                    'width': '100%',
                    'height': '100%',
                    'autoScale': true,
                    'scrolling': 'auto',
                    'transitionIn': 'elastic',
                    'transitionOut': 'none',
                    'type': 'iframe',
                    'overlayColor': '#000',
                    'hideOnOverlayClick': false,
                    onClosed: function() {
                        parent.location.reload(true);
                    }
                });

                $('a[id^="delete"]').fancybox({
                    'width': '20%',
                    'height': '20%',
                    onStart: function() {
                        return window.confirm('คุณต้องการลบรายการนี้ไหม?');
                    },
                    onClosed: function() {
                        parent.location.reload(true);
                    }
                });
            });
        </script>
    
    </head>
    <body> 
        <body class="body">
            <table align="center" width="90%">
                <tr>
                    <td colspan="2" class="header" >
                        <img src="../images/logo.png"> </a>  <img src="../images/it_service_text.png" width ="150">  
                            <hr/>
                    </td>
                </tr >

                <tr  valign="top">
                    <td class="left">
                        <?php include_once "left.php"; ?>
                    </td>
                    <td>
                        <div align="right">
                            <form
                                id="searchperson" name="txtKeyword" method="get" action="altServiceComSearchUser.php" />
                            <input name="txtKeyword" size="30" type="text" id="txtKeyword" class="validate[required]"/>
<!--                                <input type="hidden" name="hidOK">-->
                                <input type="image" name="search" id="search" value="submit" src="../images/search.png">
                            </form>

                        </div>
                        <?
                        ob_start();
                        include_once '../connect.php';
                        $strSQL2 = "SELECT * FROM `altcomservice` LEFT JOIN depart ON altcomservice.de_id = depart.id                                                                                
                                                                  LEFT JOIN employee ON altcomservice.emp_id = employee.emp_id   
                                                                  LEFT JOIN userlog  ON altcomservice.id_member = userlog.id_member
                                                                  LEFT JOIN comname ON altcomservice.cn_id = comname.cn_id
                                                                  LEFT  JOIN product_detail ON comname.cn_number =  product_detail.pd_id
                                                                  WHERE altcomservice.emp_id = '$id_member'
                                ";
                        $objQuery2 = mysql_query($strSQL2) or die("Error Query [" . $strSQL2 . "]");
                        $Num_Rows = mysql_num_rows($objQuery2);
                        $n = 1;
                        $Per_Page = 7;   // Per Page

                        $Page = $_GET["Page"];
                        if (!$_GET["Page"]) {
                            $Page = 1;
                        }

                        $Prev_Page = $Page - 1;
                        $Next_Page = $Page + 1;

                        $Page_Start = (($Per_Page * $Page) - $Per_Page);
                        if ($Num_Rows <= $Per_Page) {
                            $Num_Pages = 1;
                        } else if (($Num_Rows % $Per_Page) == 0) {
                            $Num_Pages = ($Num_Rows / $Per_Page);
                        } else {
                            $Num_Pages = ($Num_Rows / $Per_Page) + 1;
                            $Num_Pages = (int) $Num_Pages;
                        }

                        $strSQL2 .=" order  by alt_create DESC LIMIT $Page_Start , $Per_Page";
                        $objQuery2 = mysql_query($strSQL2);
                        ?>

                        <div align="right">
                            <a id="addCom" href="serviceComAdd.php">
                                <img src="../images/computer_add.png" width="40px" >
                            </a>
                            <!--                                            <a href="report_computername.php" target="bank">
                                                                            <img src="../images/print_empty.png" width="45px">
                                                                        </a>-->
                        </div>
                        <div class="nameTitle">รายชื่อเครื่องคอมพิวเตอร์</div>
                        <table width="100%"  border="0" align="center" cellpadding="1" cellspacing="0" class="simply">
                            <thead>
                                <tr>
                                    <th width="5%">ลำดับ</th>
                                    <th width="10%">รหัสเครื่อง</th>                                  
                                    <th width="15%">อาการเสีย</th>
                                    <th width="10%">ผู้แจ้ง</th>
                                    <th width="10%">แผนกฝ่าย</th>                       
                                    <th width="10%">รายงานผล</th>
                                    <th width="10%">เจ้าหน้าที่</th>  
<!--                                    <th width="5%">แก้ไข</th>
                                    <th width="5%">ลบ</th>-->
                                    <th width="5%">Report</th>
                                </tr>
                            </thead>
                            <?
                            while ($objResult2 = mysql_fetch_array($objQuery2)) {
                                ?>
                                <tbody>
                                    <tr>
                                        <td>  <?php echo $n++; ?></td>
                                        <td><?= $objResult2["pd_name"]; ?></td>                                     
                                        <td><?= $objResult2["alt_Error"]; ?></td>
                                        <td><?= $objResult2["emp_nameTh"]; ?></td>
                                        <td><?= $objResult2["departname"]; ?></td>
                                        <td><?= $objResult2["alt_status"]; ?></td>
                                        <td><?= $objResult2["f_name"]; ?></td>
    <!--                                         <td> <a id="edit" href="serviceComUpdate.php?alt_Id=<?= $objResult2["alt_Id"]; ?>">
                                                <img src="../images/write.png" width="35px" > </td>
                                                    <td align="center">
                                                        <a href="home.php?url=serviceComDelete&alt_Id=<?= $objResult2["alt_Id"]; ?>"onclick="return confirm('what do you want Delete')">
                                                            <img src="../images/deletered.png" width="35px" >
                                                        </a>
                                                    </td>-->
                                        <td> <a href="../admin/report_repaircomputer.php?alt_Id=<?= $objResult2["alt_Id"]; ?>" target="blank">
                                                <img src="../images/pdf.png" width="35px" >
                                            </a>
                                        </td> 
                                    </tr>
                                    <?
                                }
                                ?>
                            </tbody>
                        </table>
                        <table width="100%"  border="0" align="center" cellpadding="1" cellspacing="0" class="simply">
                            <tr>
                                <td>
                                    <br>
                                        Total <?= $Num_Rows; ?> Record : <?= $Num_Pages; ?> Page :
                                        <?
                                        if ($Prev_Page) {
                                            echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
                                        }

                                        for ($i = 1; $i <= $Num_Pages; $i++) {
                                            if ($i != $Page) {
                                                echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
                                            } else {
                                                echo "<b> $i </b>";
                                            }
                                        }
                                        if ($Page != $Num_Pages) {
                                            echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
                                        }
                                        ?>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>  
                <tr>
                    <td colspan="2">
                        <div><a href="../checklogout.php" onclick="return confirm('what do you want Exit')"> <img src="../images/logout.png" width="150px"></img></a></div>
                    </td>
                </tr>
                <tr>
                    <td class="footer" colspan="2">
                        Powered by Department Technology information Adinop
                    </td>
                </tr>
            </table>
        </body>
</html>